Skip to content

fix: prevent flickering in 3-way conflict diff (#317)#320

Merged
esmuellert merged 1 commit intomainfrom
dev
Mar 11, 2026
Merged

fix: prevent flickering in 3-way conflict diff (#317)#320
esmuellert merged 1 commit intomainfrom
dev

Conversation

@esmuellert
Copy link
Owner

Summary

Fixes #317 — constant flickering, cursor trapping, and forced tab switching in 3-way merge conflict mode.

Root Cause

The same-file deduplication check in on_file_select (render.lua) failed for conflict files. Conflict revisions :2/:3 match the mutable pattern ^:[0-3]$, but conflict files are not in the staged list. This caused:

  • file_has_staged ~= current_is_mutablefalse ~= true → always falls through
  • Every git-watcher refresh (~500ms) re-triggers view.update()setup_conflict_result_window()
  • Result: constant flickering, cursor forced back to modified window, can't leave CodeDiff tab

Same class of bug as the staged rename flicker fix (2a8a1f1) — deduplication failure causing repeated view rebuilds — but for conflict mode specifically.

Changes

fix(render): conflict file deduplication

Add conflict-specific early return in on_file_select: when group == "conflicts" and session already has a valid result_win, skip the update.

fix(auto_refresh): variable shadowing

Remove re-declarations of lifecycle and tabpage inside vim.schedule that shadowed the outer closure with get_current_tabpage(). Now consistently uses the correct tabpage from find_tabpage_by_buffer().

Testing

  • New test: tests/ui/conflict/conflict_dedup_spec.lua (4 tests)
  • All 29 existing conflict tests pass
  • All explorer and view tests pass

The same-file deduplication check in on_file_select failed for conflict
files because revisions :2/:3 match the mutable pattern ^:[0-3]$, but
conflict files are not in the staged list. This caused every git-watcher
refresh (~500ms) to re-trigger view.update() → setup_conflict_result_window(),
producing constant flickering, cursor trapping, and forced tab switching.

Add conflict-specific early return: when group is 'conflicts' and session
already has a valid result_win, skip the update.

Also fix variable shadowing in auto_refresh.lua where tabpage was
re-declared with get_current_tabpage() inside vim.schedule, instead of
using the correct tabpage from find_tabpage_by_buffer().

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@esmuellert esmuellert enabled auto-merge March 11, 2026 02:35
@esmuellert esmuellert merged commit 65150c8 into main Mar 11, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flickering in 3 way diff

1 participant